home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / exec / setexcept.c < prev    next >
C/C++ Source or Header  |  1996-09-12  |  2KB  |  96 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: setexcept.c,v 1.4 1996/08/13 13:56:08 digulla Exp $
  4.     $Log: setexcept.c,v $
  5.     Revision 1.4  1996/08/13 13:56:08  digulla
  6.     Replaced __AROS_LA by __AROS_LHA
  7.     Replaced some __AROS_LH*I by __AROS_LH*
  8.     Sorted and added includes
  9.  
  10.     Revision 1.3  1996/08/01 17:41:19  digulla
  11.     Added standard header for all files
  12.  
  13.     Desc:
  14.     Lang:
  15. */
  16. #include <exec/execbase.h>
  17. #include <aros/libcall.h>
  18.  
  19. /*****************************************************************************
  20.  
  21.     NAME */
  22.     #include <clib/exec_protos.h>
  23.  
  24.     __AROS_LH2(ULONG, SetExcept,
  25.  
  26. /*  SYNOPSIS */
  27.     __AROS_LHA(ULONG, newSignals, D0),
  28.     __AROS_LHA(ULONG, signalSet,  D1),
  29.  
  30. /*  LOCATION */
  31.     struct ExecBase *, SysBase, 52, Exec)
  32.  
  33. /*  FUNCTION
  34.     Change the mask of signals causing a task exception.
  35.  
  36.     INPUTS
  37.     newSignals - Set of signals causing the exception.
  38.     signalSet  - Mask of affected signals.
  39.  
  40.     RESULT
  41.     Old mask of signals causing a task exception.
  42.  
  43.     NOTES
  44.  
  45.     EXAMPLE
  46.  
  47.     BUGS
  48.  
  49.     SEE ALSO
  50.     AllocSignal(), FreeSignal(), Wait(), SetSignal(), Signal()
  51.  
  52.     INTERNALS
  53.  
  54.     HISTORY
  55.  
  56. ******************************************************************************/
  57. {
  58.     __AROS_FUNC_INIT
  59.  
  60.     struct Task *me;
  61.     ULONG old;
  62.  
  63.     /* Get pointer to current task */
  64.     me=SysBase->ThisTask;
  65.  
  66.     /* Protect mask of sent signals and task lists */
  67.     Disable();
  68.  
  69.     /* Get returncode */
  70.     old=me->tc_SigExcept;
  71.  
  72.     /* Change exception mask */
  73.     me->tc_SigExcept=(old&~signalSet)|(newSignals&signalSet);
  74.  
  75.     /* Does this change include an exception? */
  76.     if(me->tc_SigExcept&me->tc_SigRecvd)
  77.     {
  78.     /* Yes. Set the exception flag. */
  79.     me->tc_Flags|=TF_EXCEPT;
  80.  
  81.     /* Are taskswitches allowed? (Don't count own Disable() here) */
  82.     if(SysBase->TDNestCnt>=0||SysBase->IDNestCnt>0)
  83.         /* No. Store it for later. */
  84.         SysBase->AttnResched|=0x80;
  85.     else
  86.         /* Switches are allowed. Force a rescedule. */
  87.         Switch();
  88.     }
  89.     Enable();
  90.  
  91.     return old;
  92.     __AROS_FUNC_EXIT
  93. }
  94.  
  95.  
  96.